/*
 * @(#)CharmBoardXY.java $version 2013. 7. 5.
 *
 */

package com.pace.gonu.constants;

import com.pace.gonu.model.PlayRock;

/**
 * @author pace
 */
public enum CharmBoardXY {
	/*첫번째 줄 좌표*/
	r1(25, 25),
	r2(3 * BoardXY.CHARM_DISTANCE + 25, 25),
	r3(6 * BoardXY.CHARM_DISTANCE + 25, 25),
	/*두번째 줄 좌표*/
	r4(BoardXY.CHARM_DISTANCE + 25, BoardXY.CHARM_DISTANCE + 25),
	r5(3 * BoardXY.CHARM_DISTANCE + 25, BoardXY.CHARM_DISTANCE + 25),
	r6(5 * BoardXY.CHARM_DISTANCE + 25, BoardXY.CHARM_DISTANCE + 25),
	/*세번째 줄 좌표*/
	r7(2 * BoardXY.CHARM_DISTANCE + 25, 2 * BoardXY.CHARM_DISTANCE + 25),
	r8(3 * BoardXY.CHARM_DISTANCE + 25, 2 * BoardXY.CHARM_DISTANCE + 25),
	r9(4 * BoardXY.CHARM_DISTANCE + 25, 2 * BoardXY.CHARM_DISTANCE + 25),
	/*네번째 줄 좌표*/
	r10(25, 3 * BoardXY.CHARM_DISTANCE + 25),
	r11(BoardXY.CHARM_DISTANCE + 25, 3 * BoardXY.CHARM_DISTANCE + 25),
	r12(2 * BoardXY.CHARM_DISTANCE + 25, 3 * BoardXY.CHARM_DISTANCE + 25),
	r13(4 * BoardXY.CHARM_DISTANCE + 25, 3 * BoardXY.CHARM_DISTANCE + 25),
	r14(5 * BoardXY.CHARM_DISTANCE + 25, 3 * BoardXY.CHARM_DISTANCE + 25),
	r15(6 * BoardXY.CHARM_DISTANCE + 25, 3 * BoardXY.CHARM_DISTANCE + 25),
	/*다섯번째 줄 좌표*/
	r16(2 * BoardXY.CHARM_DISTANCE + 25, 4 * BoardXY.CHARM_DISTANCE + 25),
	r17(3 * BoardXY.CHARM_DISTANCE + 25, 4 * BoardXY.CHARM_DISTANCE + 25),
	r18(4 * BoardXY.CHARM_DISTANCE + 25, 4 * BoardXY.CHARM_DISTANCE + 25),
	/*여섯번째 줄 좌표*/
	r19(BoardXY.CHARM_DISTANCE + 25, 5 * BoardXY.CHARM_DISTANCE + 25),
	r20(3 * BoardXY.CHARM_DISTANCE + 25, 5 * BoardXY.CHARM_DISTANCE + 25),
	r21(5 * BoardXY.CHARM_DISTANCE + 25, 5 * BoardXY.CHARM_DISTANCE + 25),
	/*일곱번째 줄 좌표*/
	r22(25, 6 * BoardXY.CHARM_DISTANCE + 25),
	r23(3 * BoardXY.CHARM_DISTANCE + 25, 6 * BoardXY.CHARM_DISTANCE + 25),
	r24(6 * BoardXY.CHARM_DISTANCE + 25, 6 * BoardXY.CHARM_DISTANCE + 25);

	private int x;
	private int y;

	CharmBoardXY(int x, int y) {
		this.x = x;
		this.y = y;
	}

	public int getX() {
		return x;
	}

	public int getY() {
		return y;
	}

	public static int getPoint(PlayRock playRock) {
		for (CharmBoardXY boardXY : CharmBoardXY.values()) {
			if (boardXY.getX() == playRock.getPath().getX()) {
				if (boardXY.getY() == playRock.getPath().getY()) {
					return boardXY.ordinal();
				}
			}
		}
		throw new IllegalArgumentException("돌의 위치가 유효하지 않습니다.");
	}
}
